<?php
// +----------------------------------------------------------------------
// | dswjcms
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2014 http://www.tifaweb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
// +----------------------------------------------------------------------
// | Author: 宁波市鄞州区天发网络科技有限公司 <dianshiweijin@126.com>
// +----------------------------------------------------------------------
// | Released under the GNU General Public License
// +----------------------------------------------------------------------
defined('THINK_PATH') or exit();

class IndexAction extends HomeAction
{
    public function index()
    {
        $lastValue = array();
        $unite = M('unite');
        $list = $unite->where("pid= 3")->select();
        $lastValue['day'] = $this->dataProcessing($list, 1);
        $lastValue['dayCompany'] = $this->dataProcessing($list, 2);
        $amountList = $unite->where("pid= 6")->select();
        $lastValue['amount'] =  $this->dataProcessing($amountList, 1);
        $lastValue['amountCompany'] = $this->dataProcessing($amountList, 3);
        $System = M('system');
        $systemLsit = $System->order('`id` asc')->select();
        foreach ($systemLsit as $systems){
            if($systems['name'] == 'sys_InterestMF'){
                $lastValue['Interest'] = $systems['value'];
            }
            if($systems['name'] == 'sys_wFPoundage'){
                $lastValue['wFPoundage'] = $systems['value'];
            }
            if($systems['name'] == 'sys_withdrawalPoundage'){
                $lastValue['withdrawalPoundage'] = $systems['value'];
            }
        }
        echo json_encode($lastValue);
    }

    //数据处理
    public function dataProcessing($list, $type)
    {
        $day = '';
        foreach ($list as $key => $amountLists) {
            if ($type == 1) {
                $day .= $amountLists['value'] . ' ';
            } elseif ($type == 2) {
                $day .= $amountLists['value'] . '天' . ' ';
            } elseif($type == 3) {
                $day .= $amountLists['value'] . '元' . ' ';
            }
        }
        return trim($day);
    }

    //是否已经完成认证
    public function urlCheck(){
        $userinfo = M('userinfo')->where('uid=1')->find();
        if($userinfo['email_audit'] == 1){
            $result['email_audit']='已完善';
        }else{
            $result['email_audit']='未完善';
        }
        if($userinfo['cellphone_audit'] == 1){
            $result['cellphone_audit']='已完善';
        }else{
            $result['cellphone_audit']='未完善';
        }
        if($userinfo['video_audit'] == 1){
            $result['video_audit']='已完善';
        }else{
            $result['video_audit']='未完善';
        }
        if($userinfo['site_audit'] == 1){
            $result['site_audit']='已完善';
        }else{
            $result['site_audit']='未完善';
        }
        if($userinfo['zhi_audit'] == 1){
            $result['zhi_audit']='已完善';
        }else{
            $result['zhi_audit']='未完善';
        }
        echo json_encode($result);
    }

    //确认借款
    public function confirmation()
    {
        $this->display();
    }


    public function cartMation(){
        $this->display();
    }
}